#!/usr/bin/env python
# coding: utf-8

# # 图片抓取

# In[6]:


from requests_html import HTMLSession
session = HTMLSession()


# In[11]:


r = session.get('http://simpledesktops.com/browse/')


# In[12]:


r.status_code


# In[17]:


items_img = r.html.find('div.desktop > a >img')
for item in items_img:
    # print(item.attrs['title'])# 图片名称
    # print(item.attrs['src']) # 相应图片链接
    
# items_img[0].attrs['src']


# In[21]:


import requests

def save_image(url,title):
    img_response = requests.get(url)
    print(img_response.content)
    with open('bg/'+title,'wb')as file:
        file.write(img_response.content)
        
items_img = r.html.find('div.desktop > a >img')
for item in items_img:
    title = item.attrs['title']
    img_url = item.attrs['src']
    save_image(img_url,title)


# In[2]:


from requests_html import HTMLSession
session = HTMLSession()


# In[3]:


r = session.get('https://gz.lianjia.com/ershoufang/tianhe/')


# In[4]:


r.status_code


# In[6]:


esf_items = r.html.find('div.info.clear')
for item in esf_items:
    print(item.text)


# In[7]:


img_items = r.html.find('img.lj-lazy')
img_items


# In[ ]:




